import React, { Component } from 'react';

// 其他表单中的受控组件也是类似的用法 checkbox

class App extends Component {
  state ={
    checked:false
  }
  handleChange = (e) => {
    console.log(e.target.checked);
    this.setState({
      checked:e.target.checked
    })
  }
  render() {
    return (
      <div>
        <input type="checkbox" checked={this.state.checked} onChange={this.handleChange}/>
      </div>
    );
  }
}

export default App;
